
//对wx.request的二次封装


const app = getApp();

module.exports = (url,data,method="get",header={})=>{
  // loading动画  数据加载之前
  wx.showLoading({
    title: 'Loading...',
    mask: true
  })

  return  new Promise((resolve,reject)=>{
    wx.request({
      //拼接全地址
      url : app.config.apiBase + url,
      data,
      header,
      method,
      dataType:'json',
      success:resolve,
      fail:reject,
      complete: wx.hideLoading
    })

  })


}
